package com.zmn.mcc.permit.client.aop;

import com.zmn.base.common.data.dubbo.interfaces.company.CompanyListRemoteService;
import com.zmn.mcc.cas.web.StaffAdminService;
import com.zmn.mcc.common.dto.staff.LoginStaffDO;
import com.zmn.mcc.dubbo.interfaces.staff.StaffPermitRemoteService;
import com.zmn.mcc.permit.client.consts.PermitAspectTypeConsts;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.core.annotation.Order;

/**
 * controller 层切入
 *
 * @author LuJia
 * @version v1.0
 * @since 2020/06/17 17:17
 **/
@Aspect
@Order(1)
@Slf4j
public class ControllerPermitDataAspect extends BasePermitProcess {

    /**
     * 设定切入点
     */
    @Override
    @Pointcut("@annotation(com.zmn.mcc.permit.client.annotation.FilterPermitData) && (@annotation(org.springframework.web.bind.annotation.RequestMapping) || @annotation(org.springframework.web.bind.annotation.GetMapping) || @annotation(org.springframework.web.bind.annotation.PostMapping))")
    protected void pointCutMethod() {
    }

    @Override
    protected LoginStaffDO getLoginStaffDO() {
        return StaffAdminService.currentStaff();
    }

    @Override
    protected Integer getAspectType() {
        return PermitAspectTypeConsts.CONTROLLER;
    }

    public ControllerPermitDataAspect(StaffPermitRemoteService staffPermitRemoteService, CompanyListRemoteService companyListRemoteService) {
        this.staffPermitRemoteService = staffPermitRemoteService;
        this.companyListRemoteService = companyListRemoteService;
    }
}
